import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by losor on 2017/3/5.
 */
public class _455_AssignCookies {
    public static void main(String[] args) {
        int[] g = {1,2,3};
        int[] s = {1,2};

        System.out.println(findContentChildren(g,s));
    }
    public static int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int indexg = g.length - 1;
        for (int i = s.length-1; i >= 0 ; i--) {
            while (s[i] < g[indexg]) {
                indexg--;
                if (indexg==-1)
                    return count;
            }
            count++;
            indexg--;
            if (indexg==-1)
                return count;
        }
        return count;
    }
}
